package michaelgame.sprite;

import java.awt.Point;
import framework.Level;
import framework.Sprite;


/**
 * 
 * @author Michael Deng
 * 
 */
public class Bullet extends Sprite {

    private final String myImageFile = "Bullet1.gif";
    private final int myWidth = 17;
    private final int myHeight = 50;
    private final int myYVelocity = 3;

    /**
     * 
     * @param position location to initialize the sprite
     */
    @Override
    public void initialize (Point position, Level l) {
        Point newPosition = new Point(position.x, 0);
        super.superInitialize(newPosition, myImageFile, myWidth, myHeight, l);
    }

    @Override
    protected void move () {
        super.getMyCenter().translate(0, myYVelocity);
    }

    @Override
    protected void action () {
        if (super.getTop() >= super.getMyLevel().getMyGame().getMyContainer().getHeight()) {

            // deletes this sprite
            getMyLevel().markSpriteToDelete(this, "Bullet");

            // bullettracker.addbullet()
            ((BulletTracker) getMyLevel().getMySprites().get("BulletTracker").get(0)).addBullet();
        }
    }

}
